<div class="column full fl">
		
			<div class="box themed_box">

	<h2 class="box-header"><?php echo $title; ?></h2>
	<div class="box-content">
    <?php if($title==$this->lang->line('adv_search')): ?>
       <br />
       <form id="formtest" name="formtest" method="post" action="<?php //echo site_url($form['action']); ?>">
            <label><?php echo $this->lang->line('pic'); ?></label>
            <select  class="form-field width10" id="select" name="pic_search" title="Select a category">
                   <option value="-"> - </option>  
    				<?php foreach($table['users'] as $rowuser): ?>
                    <option value="<?php echo $rowuser['username']; ?>"><?php echo $rowuser['username']; ?></option>
                <?php endforeach;?>
            </select>
            
            <label><?php echo $this->lang->line('group'); ?></label>
            <select  class="form-field width10" id="select" name="group_search" title="Select a category">
                    <option value="-"> - </option>  
    				<?php foreach($table['groups'] as $rowgroup): ?>
                    <option value="<?php echo $rowgroup['id']; ?>"><?php echo $rowgroup['group_name']; ?></option>
                <?php endforeach;?>
            </select>
            
            <label><?php echo $this->lang->line('sector'); ?></label>
            <select  class="form-field width10" id="select" name="sector_search" title="Select a category">
                    <option value="-"> - </option>  
    				<?php foreach($table['sectors'] as $rowsector): ?>
                    <option value="<?php echo $rowsector['id']; ?>"><?php echo $rowsector['sector_name']; ?></option>
                <?php endforeach;?>
            </select>
            
            <label><?php echo $this->lang->line('source'); ?></label>
            <select  class="form-field width10" id="select" name="source_search" title="Select a category">
                    <option value="-"> - </option>  
    				<?php foreach($table['sources'] as $rowsource): ?>
                    <option value="<?php echo $rowsource['id']; ?>"><?php echo $rowsource['source_name']; ?></option>
                <?php endforeach;?>
            </select>
            
            <label><?php echo $this->lang->line('status'); ?></label>
            <select  class="form-field width10" id="select" name="status_search" title="Select a category">
                    <option value="-"> - </option>  
    				<?php foreach($table['status'] as $rowstatus): ?>
                    <option value="<?php echo $rowstatus['id']; ?>"><?php echo $rowstatus['status_name']; ?></option>
                <?php endforeach;?>
            </select>
            
            <input id="reset" class="button red" type="button" value="Reset" name="reset" />
			<input id="validate" class="button themed" type="submit" value="<?php echo $this->lang->line('search');?>" name="search" />
           
           
        </form>
    <?php endif; ?>
    <?php echo $this->session->flashdata('message');?>
    
	<table class="display" id="tabledata">
	<thead>
		<tr>
			<th>
            <?php if($this->session->userdata('user_pos')==$this->config->item('se')):?>
                <?php echo $this->lang->line('date');?>
            <?php else:?>
                <?php echo $this->lang->line('no');?>
            <?php endif;?>
            </th>
			<th><?='Nama PT';?></th>
			<th><?='PIC PT';?></th>
            <th><?='Tlp';?></th>
            <th><?='Ext';?></th>
			<th><?='Hp';?></th>
             <?php if($this->session->userdata('user_pos')!= $this->config->item('se')):?>
            <th><?='TA';?></th>
            <th><?='SE';?></th>
            <th><?='AE';?></th>
            <?php endif;?>
			<th><?='Status';?></th>
			<th>Action</th>
		</tr>
	</thead>
	<tbody>
	<?php
        if($title==$this->lang->line('adv_search')):
            $i=1;
        else:
            $i=1;    
        endif;
        
        //if($title<>$this->lang->line('prospect')):
            $reader=$table['customers'];
        //else:
        //    $reader=$table['csv']; 
        //endif;
        
        if(COUNT($reader)>=1):    
        foreach($reader as $rec): ?>
		<tr class="gradeX">

			<td>
            <?php if($this->session->userdata('user_pos')==$this->config->item('se')):?>
                <?=$rec['date_stamp'];?>
            <?php else:?>
               <?php if($title==$this->lang->line('adv_search')): echo $i; else: echo $i; endif; ?>
            <?php endif;?>
            </td>
			<td>
			<?php
				if($rec['total']>0)
					echo '<p style="font-weight:bold">'.$rec['customer_name'].'</p>';
				else
					echo '<p>'.$rec['customer_name'].'</p>';
			?>
				</td>
			<td><?php echo $rec['pic'] ?></td>
            <td><?php echo $rec['tlp'] ?></td>
            <td><?php echo $rec['ext'] ?></td>
			 <td><?php echo $rec['hp'] ?></td>
            <?php if($this->session->userdata('user_pos')!= $this->config->item('se')):?>
            <td><?php echo $rec['rev'] ?></td>
            <td><?php echo $rec['rev2'] ?></td>
            <td><?php echo $rec['rev3'] ?></td>
            <?php endif;?>
            
			<td>
             <?php if($this->session->userdata('user_pos')!= $this->config->item('se')):?>
                <?php echo $rec['status_name'] ?>
             <?php else:?>
                <?=form_open('customers/crm/saveActivity')?>
                <?=form_hidden('id',$rec['id']);?>
                <?=form_dropdown('status',array('1'=>'Call','2'=>'Invalid Data','4'=>'Meeting','6'=>'Follow up'),$rec['latest_activity']);?>
                <?=form_submit('go','go');?>
                <?=form_close();?>
             <?php endif;?>
            </td>
            
            <?php //if($this->session->userdata('user_group')== $this->config->item('admin')):?>
			<td class="tc width15">
               <?php if($this->session->userdata('user_group')== $this->config->item('admin')):?>  
               <a class="button white" href="<?php  echo site_url($this->config->item('cust_excel2').$rec['id']); ?>"><span class="icon_single xls"></span></a>
              <?php endif;?>
             
              <?php if($title<>$this->lang->line('prospect')): ?>
              <a class="button white" href="<?php  echo site_url($this->config->item('cust_view').$rec['id']); ?>"><span class="icon_single video"></span></a> 
              <?php else: ?>
              <a class="button white" href="<?php  echo site_url($this->config->item('cust_viewp').$rec['id']); ?>"><span class="icon_single video"></span></a> 
              <?php endif;?>
              <?php if(($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin'))):?>
              <?php if($title<>$this->lang->line('prospect')):?>  
                <a class="button white" href="<?php  echo site_url($this->config->item('cust_delete').$rec['id']); ?>"><span class="icon_single cancel"></span></a>
			  <?php endif;?>
              <?php endif;?>
              <?php if(($this->session->userdata('user_group')<> $this->config->item('manage')) ):?>
              <?php if($title<>$this->lang->line('prospect')): ?>  	
                <a class="button white" href="<?php  echo site_url($this->config->item('cust_edit').$rec['id']); ?>"><span class="icon_single edit"></span></a>
              <?php endif;?>
              <?php endif;?>  
            </td>
			<?php //endif;?>
		</tr>
	<?php
        if($title==$this->lang->line('adv_search')):
            $i++;
        else:
            $i++;    
        endif; 
        endforeach;
        endif;
    ?>	
	</tbody>
	</table>
    
    <?php if($title==$this->lang->line('prospect')): ?>
    
    <ul class="pagination">
		<?php echo form_open_multipart($this->config->item('cust_upload'));?>
			<li><input type="file" name="userfile" size="20" /></li>
			<li><button type="submit" class="button white"><?php echo $this->lang->line('import'); ?></button></li>
			<li><a class="button white" href="<?php echo site_url($this->config->item('cust_user_guide')); ?>"><?php echo $this->lang->line('user_guide'); ?></a></li>
		<?php echo form_close();?>
		
		<li>
		<?php echo form_open_multipart('customers/crm/providecust');?>
		<select name="user">
		<?php foreach($table['users'] as $user): ?>
		<option value="<?=$user['username']?>"><?=$user['username'];?></option>
		<?php endforeach;?>
		</select>
		<button class="button white" type="submit" ><?php echo $this->lang->line('insert_user'); ?></button>
		<?php echo form_close();?>
		</li>
 
		<li><a class="button white" href="<?php echo site_url($this->config->item('cust_prospuser_del')); ?>"><?php echo $this->lang->line('delete'); ?></a></li>
	</ul>
    
    <?php endif;?>
        
	<div class="clear"></div>
	</div>
	</div>
	
	</div>
	
	<?php if($title==$this->lang->line('prospect')): ?>
	<div class="column full fl">
	
		<div class="box themed_box">
			<h2 class="box-header-new"></h2>

			<h2 class="box-header"><?php echo $title.' '.$this->lang->line('pic'); ?></h2>
			<div class="box-content box-table">
			  
              <table class="tablebox">
		<thead class="table-header">
		<tr>
			<th><?php echo $this->lang->line('no');?>1</th>
			<th><?php echo $this->lang->line('cust_name');?></th>
			<th><?php echo $this->lang->line('pic');?></th>
            <th><?php echo $this->lang->line('tlp');?></th>
            <?php if( $this->session->userdata('user_pos')<> $access )   : ?>
            <th><?php echo $this->lang->line('pic');?></th>
             <?php endif;?>
			<th><?php echo $this->lang->line('id');?></th>
			<!--<th><?php echo $this->lang->line('user_group');?></th>
			<th><?php echo $this->lang->line('user_pos');?></th>-->
            <?php //if($this->session->userdata('user_group')== $this->config->item('admin')):?>
			<th>Action</th>
			<?php //endif;?>
		</tr>
		</thead>
		<tbody>
            <?php $i=1; ?>
					<?php foreach($table['prospects'] as $rec): ?>
                    <?php if($i % 2 == 0): 
                            $zebra="odd";
                          else: 
                            $zebra="even";
                          endif;
                    ?>
			<tr class="<?php echo $zebra; ?>">
			<td><?php echo $i;?></td>
			<td><?php echo $rec['customer_name'] ?></td>
			<td><?php echo $rec['pic'] ?></td>
            <td><?php echo $rec['tlp'] ?></td>
            
            <?php if( $this->session->userdata('user_pos')<> $access )  : ?>
            <?php if($title==$this->lang->line('prospect')): ?>
            <td><?php echo $rec['rev'] ?></td>
            <?php endif; ?>
			<?php endif; ?>
            <td><?php echo $rec['id'] ?></td>
			<!--<td class="center"><?php // echo $rec['group_name'] ?></td>
			<td class="center"><?php // echo $rec['pos_name'] ?></td>-->
            <?php //if($this->session->userdata('user_group')== $this->config->item('admin')):?>
			<td class="tc width15">
              <?php if($title<>$this->lang->line('prospect')): ?>
              <a class="button white" href="<?php  echo site_url($this->config->item('cust_view').$rec['id']); ?>"><span class="icon_single video"></span></a> 
              <?php else: ?>
              <a class="button white" href="<?php  echo site_url($this->config->item('cust_viewp').$rec['id']); ?>"><span class="icon_single video"></span></a> 
              <?php endif;?>
              <?php if(($this->session->userdata('user_group')== $this->config->item('admin')) || ($this->session->userdata('user_group')== $this->config->item('co_admin'))):?>
              <?php if($title<>$this->lang->line('prospect')): ?>  
                <a class="button white" href="<?php  echo site_url($this->config->item('cust_delete').$rec['id']); ?>"><span class="icon_single cancel"></span></a>
			  <?php endif;?>
              <?php endif;?>
              <?php if(($this->session->userdata('user_group')<> $this->config->item('manage')) ):?>
                <?php if($title<>$this->lang->line('prospect')): ?> 
                    <a class="button white" href="<?php  echo site_url($this->config->item('cust_edit').$rec['id']); ?>"><span class="icon_single edit"></span></a>
                <?php endif;?>
              <?php endif;?>  
            </td>
			<?php //endif;?>
			</tr>	
			<?php $i++; endforeach;?>
            
            
			
			
		</tbody>
		</table>
		<!--
		<ul class="pagination">
        <li><a class="button white active" href="<?php echo $this->config->item('cust_prospect'); ?>"><?php echo $this->lang->line('all_user'); ?></a></li>
        <?php foreach($table['users'] as $user ): ?>
		<li><a class="button white" href="<?php echo $this->config->item('cust_prospect').$user['username']; ?>"><?php echo $user['username']; ?></a></li>
		<?php endforeach;?>
        <li><a class="button white" href="<?php echo site_url($this->config->item('cust_prospuser_del')); ?>"><?php echo $this->lang->line('delete'); ?></a></li>
		</ul>
		-->
		<br/>
              
			</div>
		</div>
	
	<div class="clear"></div>
	</div>
    <?php endif;?>
    
<?php if( ($this->lang->line('customers')==$title) && ($this->session->userdata('user_group')==$this->config->item('admin'))  ): ?>
<div class="column full fr">
	
		<div class="box themed_box">
			<h2 class="box-header"><?php echo $this->lang->line('pic'); ?></h2>
			<div class="box-content">
		     <form id="formtest" name="formtest" method="post" action="<?php echo site_url($form['action']); ?>">
                <label class="form-label required"><?php echo $this->lang->line('old').' '.$this->lang->line('pic'); ?></label>
		        <select name="old_pic" class="form-field">
                    <?php foreach($table['users'] as $user): ?>
                        <option value="<?php echo $user['username']; ?>"><?php echo $user['username'].'-'.$user['name']; ?></option>
                    <?php endforeach; ?>
                </select>
			    <br />
                <label class="form-label required"><?php echo $this->lang->line('new').' '.$this->lang->line('pic'); ?></label>
		        <select name="new_pic" class="form-field">
                    <?php foreach($table['users'] as $user): ?>
                        <option value="<?php echo $user['username']; ?>"><?php echo $user['username'].'-'.$user['name']; ?></option>
                    <?php endforeach; ?>
                </select>
                <br />
                <input id="reset" class="button red" type="button" value="Reset" name="reset" />
		        <input id="validate" class="button themed" type="submit" value="<?php echo $this->lang->line('save');?>" name="save" /> 
             </form>
			</div>
		</div>
	
	<div class="clear"></div>
</div>
<?php endif;?>	    	